package com.smartstate.dataManagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smartstate.dataManagement.dto.PageDTO;
import com.smartstate.dataManagement.entity.AssetSituation;
import com.smartstate.dataManagement.mapper.AssetMapper;
import com.smartstate.dataManagement.service.AssetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AssetImpl extends ServiceImpl<AssetMapper, AssetSituation> implements AssetService {

    @Autowired
    AssetMapper assetMapper;

    @Override
    public Page<AssetSituation> queryAllPageByDTO(PageDTO pageDTO) {
        Page page = new Page(pageDTO.getPage(), pageDTO.getSize());
        QueryWrapper<AssetSituation> queryWrapper = new QueryWrapper<>();
        return assetMapper.selectPage(page, queryWrapper);
    }

    /**
     * 根据id删除园区资产
     * @param id
     * @return
     */
    @Override
    public boolean removeAssetById(int id) {
        int b = assetMapper.deleteById(id);
        if (b == 1 ){
            return true;
        }
        return false;
    }
}
